// API_EXPORT START
#ifndef __AISPEECH__WTK_API__API_VAD_H__
#define __AISPEECH__WTK_API__API_VAD_H__

#ifndef WTK_PARM_STATE
typedef enum {
    WTK_PARM_APPEND,
    WTK_PARM_END,
} wtk_parm_state_t;
#endif // WTK_PARM_STATE

#ifndef WTK_VAD_WTK_VFRAME_H_
typedef enum {
    wtk_vframe_sil = 0,
    wtk_vframe_speech,
    /*
     *  wtk_vframe_speech_end: the last speech frame of margin,used for wtk_vad2_t,which means the
     *last right margin frame,which indicate silence end;
     */
    wtk_vframe_speech_end,
} wtk_vframe_state_t;
#endif // WTK_VAD_WTK_VFRAME_H_

typedef struct vad_info {
    int vad_channel_num;
} vad_info_t;

typedef struct vad vad_t;
typedef int (*vad_notify_handler)(void *usr_data, wtk_vframe_state_t status, unsigned int offset);
typedef int (*vad_data_handler)(void *usr_data, void* data, unsigned int len);

#ifdef __cplusplus
extern "C" {
#endif

vad_t *vad_new(char *cfg_fn, unsigned is_bin);
void vad_delete(vad_t *vad);
void vad_reset(vad_t *vad);
void vad_get_info(vad_t *vad, vad_info_t *vad_info);
int vad_get_error_code();

/**
 *
 * json:
 *  {
 *      "pauseTime": 500   // ms, int
 *  }
 *
 * @param vad
 * @param json      env in json format
 * @param bytes     bytes or -1 (if json is c-type string)
 * @return
 */
int vad_start(vad_t *vad, const char *json, int bytes);
int vad_restart(vad_t *vad);
int vad_feed(vad_t *vad, wtk_parm_state_t status, const char *data, int bytes);
int vad_end(vad_t *vad);
void vad_flush(vad_t *vad);

int vad_register_handler(vad_t *vad, void *usr_data, vad_notify_handler h, void *usr_data2, vad_data_handler data_h);

#ifdef __cplusplus
};
#endif
#endif //__AISPEECH__WTK_API__API_VAD_H__
// API_EXPORT END
